package com.rongxun.hbwallet.ui.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.rongxun.hbwallet.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/5/29 18:36
 * 描述	      提升
 */

public class TaskAdapter extends DelegateAdapter.Adapter<TaskAdapter.ViewHolder> {
    private Context      mContext;
    private LayoutHelper mHelper;
    private int mCount = 1;
    private VirtualLayoutManager.LayoutParams mParams;

    public TaskAdapter(Context context, LayoutHelper helper, int count) {
        this(context, helper, count, new VirtualLayoutManager.LayoutParams(VirtualLayoutManager.LayoutParams.MATCH_PARENT, VirtualLayoutManager.LayoutParams.WRAP_CONTENT));
    }

    public TaskAdapter(Context context, LayoutHelper helper, int count, VirtualLayoutManager.LayoutParams params) {
        mContext = context;
        mHelper = helper;
        mCount = count;
        mParams = params;

    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return mHelper;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_moretasks_title, parent, false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

    }

    @Override
    protected void onBindViewHolderWithOffset(ViewHolder holder, int position, int offsetTotal) {
        super.onBindViewHolderWithOffset(holder, position, offsetTotal);
        if (position==offsetTotal){
            holder.mTitle.setText(mContext.getString(R.string.daily_tasks));
        }else{
            holder.mTitle.setText(mContext.getString(R.string.base_task));
        }
    }

    @Override
    public int getItemCount() {
        return mCount;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.moretasks_tv_title)
        TextView mTitle;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

    }
}
